/*
package com.ruoyi.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

@Service
public class RabbitMQProducerService {

    private static final Logger logger = LoggerFactory.getLogger(RabbitMQProducerService.class);

    private final AtomicInteger messageCounter = new AtomicInteger(1);

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Value("${app.rabbitmq.exchange}")
    private String exchangeName;

    @Value("${app.rabbitmq.routing-key}")
    private String routingKey;

    */
/**
     * 发送简单消息
     *//*

    public String sendMessage(String content, String sender) {
        String messageId = UUID.randomUUID().toString();
        int messageNumber = messageCounter.getAndIncrement();

        RabbitMQMessageVo message = new RabbitMQMessageVo(
                messageId,
                content,
                sender,
                messageNumber
        );

        try {
            rabbitTemplate.convertAndSend(exchangeName, routingKey, message);
            logger.info("消息发送成功 [ID: {}, 发送者: {}, 内容: {}]",
                    messageId, sender, content);
            return "消息发送成功: " + messageId;
        } catch (Exception e) {
            logger.error("消息发送失败 [ID: {}, 发送者: {}]: {}",
                    messageId, sender, e.getMessage());
            e.printStackTrace();
            return "消息发送失败: " + e.getMessage();
        }
    }

    */
/**
     * 模拟多个用户并发发送消息
     *//*

    public void sendConcurrentMessages(int messageCount) {
        String[] users = {"Alice", "Bob", "Charlie", "David", "Eve"};

        for (int i = 0; i < messageCount; i++) {
            String user = users[i % users.length];
            String content = "消息内容 " + (i + 1) + " 来自 " + user;

            // 使用新线程模拟并发发送
            new Thread(() -> {
                sendMessage(content, user);
            }).start();

            // 添加小延迟，模拟真实并发场景
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }
}
*/
